<?php
namespace common\models;

use Yii;

/**
 * This is the model class for table "cart".
 *
 * @property integer $id
 * @property integer $gid
 * @property integer $uid
 * @property integer $created_at
 * @property integer $num
 */
class Cart extends \yii\db\ActiveRecord
{

    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'cart';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [
                [
                    'gid',
                    'uid',
                    'created_at',
                    'num'
                ],
                'required'
            ],
            [
                [
                    'gid',
                    'uid',
                    'created_at',
                    'num'
                ],
                'integer'
            ]
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'gid' => 'Gid',
            'uid' => 'Uid',
            'created_at' => 'Created At',
            'num' => 'Num'
        ];
    }

    public function getGoods()
    {
        return $this->hasOne(Goods::className(), [
            'id' => 'gid'
        ]);
    }
}
